﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminSite.Master" AutoEventWireup="true" CodeBehind="ProductStatistics.aspx.cs" Inherits="Agents.Admin.ProductStatistics" %>

<asp:Content ID="Header" ContentPlaceHolderID="Header" runat="server">
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        סטטיסטיקות על מוצרים
    </h1>
    <hr />

    <asp:RadioButton ID="radTopProducts" runat="server" CssClass="combobox" Checked="true" 
                        Text="המוצרים המובילים" GroupName="ReportToShow" AutoPostBack="true"
                        OnCheckedChanged="radReport_CheckedChanged" />
    <asp:RadioButton ID="radSalesByProduct" runat="server" CssClass="combobox" Checked="false" 
                        Text="מכירות לפי מוצר" GroupName="ReportToShow" AutoPostBack="true" 
                        OnCheckedChanged="radReport_CheckedChanged" />
    
    <asp:Panel ID="panelTopProducts" runat="server" GroupingText="המוצרים המובילים">
        <b>סוג הדו"ח: </b>
        <asp:RadioButton ID="radMostSelling" runat="server" CssClass="combobox" Checked="true" 
                        Text="המוצרים הנמכרים ביותר" GroupName="ReportType" 
                        OnCheckedChanged="rad_CheckedChanged" AutoPostBack="true" />
        <asp:RadioButton ID="radLeastSelling" runat="server" CssClass="combobox" Checked="false" 
                        Text="המוצרים הכי פחות נמכרים" GroupName="ReportType" 
                        OnCheckedChanged="rad_CheckedChanged" AutoPostBack="true" />
        <br /><b>קריטריון: </b>
        <asp:RadioButton ID="radCreteriaOrders" runat="server" CssClass="combobox" Checked="true" 
                        Text="הכי הרבה הזמנות" GroupName="creteria" 
                        OnCheckedChanged="rad_CheckedChanged" AutoPostBack="true" />
        <asp:RadioButton ID="radCreteriaItems" runat="server" CssClass="combobox" Checked="false" 
                        Text="הכי הרבה פריטים בכל ההזמנות" GroupName="creteria" 
                        OnCheckedChanged="rad_CheckedChanged" AutoPostBack="true" />
        <asp:RadioButton ID="radMostRecently" runat="server" CssClass="combobox" Checked="false" 
                        Text="הוזמנו הכי לאחרונה" GroupName="creteria" 
                        OnCheckedChanged="rad_CheckedChanged" AutoPostBack="true" />
        <br />

        <asp:DataGrid runat="server" ID="dgProducts" AutoGenerateColumns="False"
            BackColor="White" BorderStyle="None" 
            CellPadding="3" GridLines="Both" CssClass="dataGrid" 
            Font-Names="Verdana" BorderColor="#999999" BorderWidth="1px" 
            onitemdatabound="dgProducts_ItemDataBound">
            <AlternatingItemStyle BackColor="#DCDCDC" />
            <Columns>
                <asp:BoundColumn DataField="Id" Visible="false" />
                <asp:BoundColumn DataField="Name" HeaderText="שם" />
                <asp:BoundColumn DataField="Price" HeaderText="מחיר" DataFormatString="{0:F2}" />
                <asp:BoundColumn DataField="CategoryId" Visible="false" />
                <asp:TemplateColumn HeaderText="קטגוריה">
                    <ItemTemplate>
                        <asp:Label ID="lblCategoryName" runat="server" Text="">
                        </asp:Label>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:BoundColumn DataField="NumOfOrders" HeaderText="מס' הזמנות" />
                <asp:BoundColumn DataField="NumOfItemsInAllOrders" HeaderText="מס' פריטים" />
                <asp:BoundColumn DataField="LastOrderDate" HeaderText="הזמנה אחרונה" DataFormatString="{0:d}" />
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <ItemStyle BackColor="White" ForeColor="Black" />
            <PagerStyle Mode="NumericPages" BackColor="#999999" ForeColor="Black" HorizontalAlign="Center">
            </PagerStyle>
            <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        </asp:DataGrid>
    </asp:Panel>
   
    <asp:Panel ID="panelSalesByProduct" runat="server" GroupingText="מכירות לפי מוצר">
       בחר מוצר:
        <asp:DropDownList ID="cmbProducts" runat="server" AutoPostBack="true"
            DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id" 
            OnSelectedIndexChanged="cmbProducts_SelectedIndexChanged"
            OnDataBound="cmbProducts_SelectedIndexChanged" />
        <br />
        בחר טווח זמנים:
        <asp:RadioButtonList ID="radTimeResolution" runat="server" AutoPostBack="true"
            onselectedindexchanged="radTimeResolution_SelectedIndexChanged">
            <asp:ListItem Value="YearByMonths" Text="חודשים בשנה האחרונה" Selected="True" />
            <asp:ListItem Value="MonthByDays" Text="ימים בחודש האחרון" Selected="False" />
        </asp:RadioButtonList>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AgentConnectionString %>" 
            SelectCommand="SELECT [Id], [Name] FROM [Products] ORDER BY [Name]">
        </asp:SqlDataSource>
        <asp:Chart ID="productSellsChart" runat="server">
            <Legends>
                <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default" LegendStyle="Row" />
            </Legends>
            <Series>
                <asp:Series Name="dataSeries" ChartType="Column" IsValueShownAsLabel="true"
                            IsVisibleInLegend="false">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="chartArea" Area3DStyle-Enable3D="true">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
    </asp:Panel>

    <hr />
    <div class="alignCenter">
        <asp:Button ID="backBtn" Text="חזור" runat="server" onclick="backBtn_Click" CssClass="button"/>
    </div>
</asp:Content>
